﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class ArenaConfig extends Object
    {
        private var _map:Dictionary;
        private static var _instance:ArenaConfig;

        public function ArenaConfig()
        {
            this._map = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" ArenaConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_arena_config.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TArenaConfig = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TArenaConfig();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._map[_loc_2.id] = _loc_2;
            }
            return;
        }// end function

        public function getInfosByTypeAndLevel(param1:int, param2:int, param3:int = 0) : Array
        {
            var _loc_5:TArenaConfig = null;
            var _loc_4:Array = [];
            for each (_loc_5 in this._map)
            {
                
                if (_loc_5.type == param2 && _loc_5.copyType == param1)
                {
                    if (param3 == 0 || param3 > 0 && param3 == _loc_5.cond)
                    {
                        _loc_4.push(_loc_5);
                    }
                }
            }
            return _loc_4;
        }// end function

        public function getInfosByType(param1:int, param2:int) : Array
        {
            var _loc_4:TArenaConfig = null;
            var _loc_3:Array = [];
            for each (_loc_4 in this._map)
            {
                
                if (_loc_4.type == param1 && _loc_4.copyType == param2)
                {
                    _loc_3.push(_loc_4);
                }
            }
            return _loc_3;
        }// end function

        public function getArenaMoneyCode(param1:int, param2:int, param3:int) : int
        {
            var _loc_4:TArenaConfig = null;
            for each (_loc_4 in this._map)
            {
                
                if (_loc_4.type == param1 && _loc_4.cond == param2 && param3 == _loc_4.copyType)
                {
                    return _loc_4.valExTend2;
                }
            }
            return 0;
        }// end function

        public function get getConfig() : Dictionary
        {
            return this._map;
        }// end function

        public static function get instance() : ArenaConfig
        {
            if (_instance == null)
            {
                _instance = new ArenaConfig;
            }
            return _instance;
        }// end function

    }
}
